package MtG.client.panels;


import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JPanel;

import MtG.client.panels.cardPanelComponents.gameGards.NoCard;
import MtG.publicClass.Card;
import MtG.publicClass.Player;

/**
 * CardPanel.java is the class that designs the "cards in hand" area 
 * where all the cards in play will be situated.
 * @author Marek Sirp
 * @author Jaan Sepp
 */
public class CardPanel extends JPanel{
	/**
	 * Determines if a de-serialized file is compatible with this class.
	 */
	private static final long serialVersionUID = 5865582071623657996L;
	private final int MAXCARDSINROW = 7;
	
	
	/**
	 * Constructor.
	 */
	public CardPanel(){
		setBackground(Color.YELLOW);
		setName("CardPanel");	
		setLayout(new FlowLayout(FlowLayout.LEADING));
	}

	/**
	 * @param p player, whose cards will be placed on the panel.
	 */
	public void placeDeck(Player p){
	this.removeAll();
	int glSlotsFilled = 0;
	if( p.getPlayersHand() != null){
		for(Card c : p.getPlayersHand()){
			MtG.client.panels.cardPanelComponents.gameGards.Card mtg = new MtG.client.panels.cardPanelComponents.gameGards.Card(c);
			add(mtg);
			glSlotsFilled++;
		}
	}
	while(glSlotsFilled !=MAXCARDSINROW){
		add(new NoCard());
		glSlotsFilled++;
	}
	revalidate();
	repaint();
	}
}
